package com.qin.mall.controller.discountController;

import com.qin.mall.common.api.CommonResult;
import com.qin.malldiscount.domain.SmsFlashPromotionSession;
import com.qin.malldiscount.dto.SmsFlashPromotionSessionDetail;
import com.qin.mall.openfeign.discount.SmsFlashPromotionSessionFeigin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 限时购场次管理 远程调用
 * @author Leisure
 * create 2022 2022/11/24 23:26
 **/
@RestController
@RequestMapping("/flashSession")
public class FlashPromotionSessionController {
    
    @Autowired
    private SmsFlashPromotionSessionFeigin flashPromotionSessionFeigin;

    /**
     * 添加场次
     */
    @PostMapping("/create")
    @ResponseBody
    public CommonResult create(@RequestBody SmsFlashPromotionSession promotionSession) {
        CommonResult result = flashPromotionSessionFeigin.create(promotionSession);
        return result;
    }

    /**
     * 修改场次
     */
    @RequestMapping("/update/{id}")
    @ResponseBody
    public CommonResult update(@PathVariable Long id, @RequestBody SmsFlashPromotionSession promotionSession) {
        CommonResult count = flashPromotionSessionFeigin.update(id, promotionSession);
        return count;
    }

    /**
     * 修改启用状态
     */
    @PostMapping("/update/status/{id}")
    @ResponseBody
    public CommonResult updateStatus(@PathVariable Long id, @RequestParam Integer status) {
        CommonResult count = flashPromotionSessionFeigin.updateStatus(id, status);
        return count;
    }

    /**
     * 删除场次
     */
    @PostMapping("/delete/{id}")
    @ResponseBody
    public CommonResult delete(@PathVariable Long id) {
        CommonResult count = flashPromotionSessionFeigin.delete(id);
        return count;
    }

    /**
     * 获取场次详情
     */
    @GetMapping("/{id}")
    @ResponseBody
    public CommonResult<SmsFlashPromotionSession> getItem(@PathVariable Long id) {
        CommonResult<SmsFlashPromotionSession> count = flashPromotionSessionFeigin.getItem(id);
        return count;
    }

    /**
     * 获取全部场次
     */
    @GetMapping("/list")
    @ResponseBody
    public CommonResult<List<SmsFlashPromotionSession>> list() {
        CommonResult<List<SmsFlashPromotionSession>> result = flashPromotionSessionFeigin.list();
        return result;
    }

    /**
     * 获取全部可选场次及其数量
     */
    @GetMapping("/selectList")
    @ResponseBody
    public CommonResult<List<SmsFlashPromotionSessionDetail>> selectList(@RequestParam Long flashPromotionId) {
        CommonResult<List<SmsFlashPromotionSessionDetail>> list = flashPromotionSessionFeigin.selectList(flashPromotionId);
        return list;
    }
    
    
}
